<template>
	<view class="confirm-order">
		<Line />
		<!-- 地址 -->
		<view class="order-map" @tap="goPathList">
			<template v-if="getDefaultPath">
				<view class="map-title">
					<view class="map-name">收件人: {{getDefaultPath.name}}</view>
					<view>{{getDefaultPath.tel}}</view>
				</view>
				<view class="map-city">收货地址: {{getDefaultPath.city}} {{getDefaultPath.details}}</view>
			</template>
			<template v-else>
				<view class="map-else-title">
					<view class="map-name">请选择地址</view>
				</view>
			</template>
		</view>
		<!-- 商品 -->
		<view class="order-goods">
			<view class="goods-content" v-for="(item,index) in list" :key="index">
				<image class="goods-img" :src="item.imgUrl" mode=""></image>
				<view class="goods-text">
					<view class="goods-name">{{item.name}}</view>
					<view class="goods-size f-color">颜色分类: 黑色</view>
					<view class="f-active-color goods-size">7天无理由</view>
				</view>
				<view>
					<view>¥{{item.pprice}}</view>
					<view class="f-color">*{{item.num}}</view>
				</view>
			</view>
		</view>
		<!-- 底部: 提交订单 -->
		<view class="order-foot">
			<view>合计: <text class="order-foot-text f-active-color">¥{{$store.getters.totalPrice}}</text></view>
			<view class="confirm" @tap="goPayment">提交订单</view>
		</view>
	</view>
</template>

<script>
	import Line from "@/components/Line/Line.vue"
	export default {
		data() {
			return {
				path: this.getDefaultPath
			};
		},
		onLoad() {
			
		},
		methods:{
			//跳转到地址管理页面
			goPathList(){
				uni.navigateTo({
					url:"/pages/my-path-list/my-path-list?type=selectedPath"
				})
			},
			goPayment(){
				if(this.getDefaultPath){
					uni.navigateTo({
						url:"/pages/payment/payment"
					})
				}else{
					uni.showToast({
						title:"请选择收货地址",
						icon:"none"
					})
				}
				
			}
		},
		computed:{
			getDefaultPath(){
				if (this.$store.getters.isDefaultPath) {
					return this.$store.getters.isDefaultPath[0]
				}else{
					return false
				}
			},
			list(){
				return this.$store.state.cart.list
			}
		}
	}
</script>

<style lang="scss" scoped>
	.confirm-order {
		position: absolute;
		left: 0;
		right: 0;
		top: 0;
		bottom: 0;
		background-color: #f7f7f7;

		//收货人信息
		.order-map {
			background-color: #fff;
			line-height: 40rpx;
			padding: 20rpx;

			.map-title {
				display: flex;
				justify-content: space-between;

				.map-name {
					font-weight: bold;
				}
			}

			.map-city {
				margin-top: 10rpx;
			}
			//没有默认地址的样式
			.map-else-title {
				display: flex;
				justify-content: center;
				background-color: #fff;
				font-weight: bold;
				padding-top: 20rpx;
			}
		}

		//商品
		.order-goods {
			padding: 20rpx 0;
			background-color: #fff;

			.goods-content {
				display: flex;
				justify-content: space-between;
				align-items: center;
				background-color: #f7f7f7;
				padding: 20rpx;
				margin-top: 20rpx;

				.goods-img {
					width: 160rpx;
					height: 160rpx;
				}

				.goods-text {
					display: flex;
					flex-direction: column;
					justify-content: space-around;
					width: 360rpx;
					height: 160rpx;
					padding: 0 10rpx;

					.goods-name {
						display: -webkit-box;
						-webkit-line-clamp: 2;
						-webkit-box-orient: vertical;
						overflow: hidden;
						text-overflow: ellipsis;
						font-size: 26rpx;
						height: 68rpx;
					}

					.goods-size {
						font-size: 24rpx;
					}
				}
			}
		}

		// 底部
		.order-foot {
			display: flex;
			justify-content: flex-end;
			align-items: center;
			position: fixed;
			bottom: 0;
			left: 0;
			background-color: #fff;
			width: 100%;
			height: 80rpx;

			.order-foot-text {
				margin-left: 10rpx;
			}

			.confirm {
				margin-left: 20rpx;
				color: #fff;
				background-color: #49bdfb;
				padding: 0 30rpx;
				height: 80rpx;
				line-height: 80rpx;
			}
		}
	}
</style>
